#include <buola/image/format.h>
#include <buola/image/io.h>
#include <buola/image/drawing/basic.h>
#include <buola/image/adaptors.h>
#include <buola/image/views/cmaskedview.h>
#include <buola/image/rasterizer/cscanlinerasterizer.h>
#include <buola/image/rasterizer/cscanline.h>
#include <buola/image/cpath.h>
#include <buola/image/cimagegc.h>
#include <buola/image/vertex/cbspline.h>

using namespace buola;

int main()
{
    img::CImage_rgb8 lImage({320,400},img::CColor(L"DarkGray"));

    img::CImageGC<img::TFormat_rgb8> lGC(lImage);

    lGC.SetLineWidth(3.5);
//    lGC.SetLineCap(img::ELineCap::SQUARE);
    lGC.SetLineJoin(img::ELineJoin::MITER);

    start_timer();
    for(int i=0;i<1000;i++)
    {
        CPoint_d lCenter(128,128);
        double lRadius=100.0;
        double lAngle1=deg2rad(45.0);
        double lAngle2=deg2rad(180.0);

        lGC.SetLineWidth(10.0);
        lGC.Path().Arc(lCenter,lRadius,lAngle1,lAngle2);
        lGC.StrokePath();
        
        lGC.SetSource(img::CColor(1,0.2,0.2,0.6));
        lGC.SetLineWidth(6.0);

        lGC.Path().Arc(lCenter,10.0,0,2*M_PI);
        lGC.FillPath();

        lGC.Path().Arc(lCenter,lRadius,lAngle1,lAngle1);
        lGC.Path().LineTo(lCenter);
        lGC.Path().Arc(lCenter,lRadius,lAngle2,lAngle2);
        lGC.Path().LineTo(lCenter);
        lGC.StrokePath();
    }
    end_timer();

    img::save(lImage,io::file("agg8.ppm"));
}
